/**
 * 判断终端环境
 * @author 许明浩 微信: muaiyuese
 */

/**
 * 判断是否微信浏览器打开
 * @param {}
 * @return
 */
export const isWeChat = () => {
  if (process.env.TARO_ENV === "h5" && window?.navigator?.userAgent) {
    const ua: any = window.navigator.userAgent.toLowerCase();
    return ua.toLocaleLowerCase().includes("micromessenger"); // 判定为true则是微信浏览器，false则不是
  } else {
  }
};

/**
 * 判断IOS环境
 * @param {}
 * @return
 */
export const isIOS = () => {
  if (process.env.TARO_ENV === "h5") {
    const u = window?.navigator?.userAgent;
    const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
    return isiOS;
  } else if (process.env.TARO_ENV === "weapp") {
    const info = wx.getSystemInfoSync();
    if (info.system.indexOf("Android") > -1) {
      return false;
    } else {
      return true;
    }
  }
};
